
# exchange数据切换
def  exchange():
     a = [1,2,3,4,5]
     b = []
     for i in a:
         q =i * 10
         b.append(q)
     print(b)

# exchange数据切换
def  exchange():
     a = [1,2,3,4,5]
     b = []
     for i in a:
         q =i * 10
         b.append(q)
     print(b)

#export
def exportlist():
    a = [1, 2, 3, 4, 5]
    sec = [each_t * 60 for each_t in a]
    print(sec)
def updatebycut():
    a = [1,2,3,4,5,6,7,8,9,10]
    a[::2] = [0,0,0,0,0]
    print(a)
#
def indexlist():
    list = ["zhangsan","lisi","wangwu","zhouliu"]
    index = list.index("zhangsan")
    print(index)
def countdemo():
    list = [1,1,2,3,4,5,6,7,8,9,1,2,3,4,5,8,6,1,4]
    print(list.count(1))
# reverse逆序
def reversedemo():
    list = ["zhangsan","lisi","wangwu","zhouliu"]
    print(list[::-1])
    list.reverse()
    print(list)
# sort排序
def sortdemo():
    numbers = [12,34,3.14,99,-10]
    numbers.sort(reverse=True)
    print(numbers)
#sortde自动排序
def sorteddemo():
    list = ["1","5","4","3"]
    data = sorted(list)
    print(list)
    print(data)
def demo():
    data = [12.04,11.15,13.47,13.58,12.04,12.04,11.15,12.58,11.15]
    # 1
    num = len(data)
    print(data)
    print(num)
    times = data.count(12.04)
    print(times)

    minx = min(data)
    print(minx)
    data.remove(minx)
    print(data)
#dim2列表
def dim2():
    persons = [["tom",25,1.78],["terry",30,1.80],["lili",22,1.68]]
    for p in persons:
        print(p)
        for i in p:
            print(i)
def dim2spacail():
    persons = [["tom",25,1.78],["terry",30,1.80],["lili",22,1.68]]
    for person in persons:
        print(person)
        print(person[2])
#拷贝--浅拷贝
def copydemo():
    list1 = [1,2,3]
    list2 = list1
    print(list2)
    list2[0] = 100
    print(list1)
def createdic():
    stu = {"zhangli": 58,"lily": 70}
    print(stu)
    for i in stu:
        print(i,stu[i])
#消除
def deldemo():
    stu = {"zhangli": 58,"lily": 70}
    del stu["lily"]
    print(stu)
def getdemo():
    stu = {"zhangli": 58, "lily": 70}

    data = stu["zhangli"]
    print(data)

    data2 = stu.get("zhangli")
    print(data2)
#例题
def dicdemo():
    stu = {"张琳":58,"孙治平":70,"徐小伟":89,"徐丽苹":69,"童万丽":90}
    # 1
    dicdata = {"张琳":"缺考"}
    stu.update(dicdata)
    print(stu)
    # 2
    stu["张琳"] = 60
    print(stu)
    # 3
    del stu["徐小伟"]
    print(stu)
    # 4
    # 5
    print("人数",len(stu))
    # 6
    name = input('请输入名字:')
    if name in stu:
        print('该同学的成绩为:',stu[name])
    else:
        print("没有找到该同学")

#         闰年平年
def isLeapYear(year):
    if year % 4 == 0 or year % 400:
        print(year ,"是闰年")
        return Ture
    else:
        print(year,"不是闰年")
        return False
#   缺省参数
def printInfo(name,age  =3):
    print("你好%s,年龄为:%d岁"%(name,age))
#       不定长参数
def getconsume(month,*monry):
    all = 0
    for one in money:
        all +=one
        print("%s月总支出额为: %d元"% (month,all))


#定义汽车
class car:
    def __init__(self,name,color):#   构造函数
        self.name = name
        self.color = color

        def letsGo(self):  #定义letgo函数，类中函数称为方法
            print("go go go")

import time as time

class Hero:
    def __init__(self,name,blood,attack,defense):
        self.blood = blood
        self.attack = attack
        self.defense = defense
        self.name = name

        print(name,"英雄已初始化!")


        #定义攻击函数
    def do_attack(self,other):

        print(self.name ,"正在攻击", other.name)
        other.blood = other.blood + other.defense - self.attack
        #if other.blood <= 0:
        print(other.name ," 血量 " , other.blood)
        return other.blood



if __name__ == '__main__':
    exchange()